public class Euler001 {

	public static void main(String[] args) {
		int i = 0;
		int sum = 0;
		while (i < 1000) {
			if (i % 3 == 0 || i % 5 == 0) {
				sum = sum + i;
			}
			i = i + 1;
		}
		System.out.println("I: " + i + "\tSum: " + sum);
		// Mathematical way
		// Make me remember back to these first day with Math :(
		// Sum of 3 + sum of 5 - sum of 15 
		
		final int divisor3 = 999/3;
		final int divisor5 = 999/5;
		final int divisor15 = 999/15;
		System.out.println("SUM: " 
				+ (3*divisor3*(1+divisor3)/2 
				+ 5*divisor5*(1+divisor5)/2 
				- 15*divisor15*(1+divisor15)/2));
	}
}
